<template>
	<view>
		<view class='my-order'>
	
	<!-- 订单状态分为已搶購、搶購中、轉讓中、已轉讓；
	支付狀態有待付款、已付款、待收款、已收款		 -->
		<view class="list" v-for="item in 6">
				<view class="flex_tit">
					<view class="">预约场次:</view>
					<view class="tit">313</view>
				</view>
				<view class="flex_tit">
					<view class="">订单状态:</view>
					<view class="tit">已搶購</view>
				</view>
				<view class="flex_tit">
					<view class="">支付狀態:</view>
					<view class="tit">待付款</view>
				</view>
				<view class="flex_tit">
					<view class="">预约时间:</view>
					<view class="tit">313</view>
				</view>
		</view>
				
				
			
			
			
			
			<view class='loadingicon acea-row row-center-wrapper' v-if="orderList.length>0">
				<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
			</view>
			<!-- <view v-if="orderList.length == 0">
				<emptyPage title="暂无订单~"></emptyPage>
			</view> -->
		</view>
		<view class='noCart' v-if="orderList.length == 0 && page > 1">
			<view class='pictrue'>
				<image src='/images/noOrder.png'></image>
			</view>
		</view>
		
		<home></home>
		<!-- <payment :payMode='payMode' :pay_close="pay_close" @onChangeFun='onChangeFun' :order_id="pay_order_id" :totalPrice='totalPrice'></payment> -->
	</view>
</template>

<script>
	import {
		getOrderList,
		orderData,
		orderCancel,
		orderDel
	} from '@/api/order.js';
	import {
		openOrderSubscribe
	} from '@/utils/SubscribeMessage.js';
	import home from '@/components/home';
	import payment from '@/components/payment';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	
	import emptyPage from '@/components/emptyPage.vue'
	export default {
		components: {
			payment,
			home,
			emptyPage,
			// #ifdef MP
			authorize
			// #endif
		},
		data() {
			return {
				loading: false, //是否加载中
				loadend: false, //是否加载完毕
				loadTitle: this.$t('public.tips.load-more'), //提示语
				orderList: [], //订单数组
				orderData: {}, //订单详细统计
				orderStatus: 0, //订单状态
				page: 1,
				limit: 20,
				pay_close: false,
				pay_order_id: '',
				totalPrice: '0',
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false //是否隐藏授权
			};
		},
		computed: mapGetters(['isLogin', 'userInfo']),
		onShow() {
			// if (this.isLogin) {
			// 	this.loadend = false;
			// 	this.page = 1;
			// 	this.$set(this, 'orderList', []);
			// 	this.getOrderData();
			// 	this.getOrderList();
			// 	this.payMode[1].number = this.userInfo.nowMoney;
			// 	this.$set(this, 'payMode', this.payMode);
			// } else {
			// 	toLogin();
			// }
		},
		methods: {
			
			/**
			 * 生命周期函数--监听页面加载
			 */
			onLoad: function(options) {
				if (options.status) this.orderStatus = options.status;
			},
			/**
			 * 获取订单统计数据
			 * 
			 */
			getOrderData: function() {
				let that = this;
				orderData().then(res => {
					that.$set(that, 'orderData', res.data);
				})
			},
			
			
			/**
			 * 切换类型
			 */
			statusClick: function(status) {
				if (status == this.orderStatus) return;
				this.orderStatus = status;
				this.loadend = false;
				this.page = 1;
				this.$set(this, 'orderList', []);
				this.getOrderList();
			},
			/**
			 * 获取订单列表
			 */
			getOrderList: function() {
				let that = this;
				if (that.loadend) return;
				if (that.loading) return;
				that.loading = true;
				that.loadTitle = this.$t('public.tips.load-more');
				getOrderList({
					type: that.orderStatus,
					page: that.page,
					limit: that.limit,
				}).then(res => {
					let list = res.data.list || [];
					let loadend = list.length < that.limit;
					that.orderList = that.$util.SplitArray(list, that.orderList);
					that.$set(that, 'orderList', that.orderList);
					that.loadend = loadend;
					that.loading = false;
					that.loadTitle = loadend ? "我也是有底线的" : this.$t('public.tips.load-more');
					that.page = that.page + 1;
				}).catch(err => {
					that.loading = false;
					that.loadTitle = this.$t('public.tips.load-more');
				})
			},
		},
		onReachBottom: function() {
			this.getOrderList();
		}
	}
</script>

<style scoped lang="scss">
	.list{
		display: flex;
		flex-direction: column;
	}
	.flex_tit{
		display: flex;
		padding: 3px 5px;
		.tit{
			margin-left: 5px;
		}
	}
	
	.my-order .header {
		height: 250rpx;
		padding: 0 30rpx;
	}

	.my-order .header .picTxt {
		height: 190rpx;
	}

	.my-order .header .picTxt .text {
		color: rgba(255, 255, 255, 0.8);
		font-size: 26rpx;
		font-family: 'Guildford Pro';
	}

	.my-order .header .picTxt .text .name {
		font-size: 34rpx;
		font-weight: bold;
		color: #fff;
		margin-bottom: 20rpx;
	}

	.my-order .header .picTxt .pictrue {
		width: 122rpx;
		height: 109rpx;
	}

	.my-order .header .picTxt .pictrue image {
		width: 100%;
		height: 100%;
	}

	.my-order .nav {
		background-color: #fff;
		// width: 690rpx;
		// height: 140rpx;
		border-radius: 14rpx;
		// margin: -60rpx auto 0 auto;
	}

	.my-order .nav .item {
		text-align: center;
		// font-size: 26rpx;
		color: #282828;
		padding: 26rpx 0;
	}

	.my-order .nav .item.on {
		// font-weight: bold;
		// border-bottom: 5rpx solid #e93323;
		/* #ifdef H5 || MP */
		font-weight: bold;
		/* #endif */
		border-bottom: 5rpx solid $theme-color;
	}

	.my-order .nav .item .num {
		margin-top: 18rpx;
	}

	.my-order .list {
		// width: 690rpx;
		// margin: 14rpx auto 0 auto;
		background-color: #fff;
		margin: 10px;
		padding: 8px;
		
		.topBox{
			display: flex;
		
			.right_box{
				flex: 1;
				.countDown{
					color: rgb(217,0,27);
					padding:3px 0 10px 0;
				}
				.num_Box{
					display: flex;
					.num_pic{
						font-size: 18px;
						font-weight: 700;
					}
					.earnings{
						margin: 3px 8px;
						color: rgb(115,150,58);
					}
				}
				
			}
			.info_img{
				background-color: aqua;
				width: 70px;
				height: 70px;
				margin-right: 10px;
			}
			.list_txt{
				display: flex;
				justify-content: space-between;
				
				flex: 1;
			}
		}
		.creat{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin: 6px 0;
			.btn_flex{
				display: flex;
				.checkBtn{
					margin-left: 10px;
				}
			}
		}
	}

	.my-order .list .item {
		background-color: #fff;
		border-radius: 14rpx;
		margin-bottom: 14rpx;
	}

	.my-order .list .item .title {
		height: 84rpx;
		padding: 0 24rpx;
		border-bottom: 1rpx solid #eee;
		font-size: 28rpx;
		color: #282828;
	}

	.my-order .list .item .title .sign {
		font-size: 24rpx;
		padding: 0 13rpx;
		height: 36rpx;
		margin-right: 15rpx;
		border-radius: 18rpx;
	}

	.my-order .list .item .item-info {
		padding: 0 24rpx;
		margin-top: 22rpx;
	}

	.my-order .list .item .item-info .pictrue {
		width: 120rpx;
		height: 120rpx;
	}

	.my-order .list .item .item-info .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 14rpx;
	}

	.my-order .list .item .item-info .text {
		width: 500rpx;
		font-size: 28rpx;
		color: #999;
	}

	.my-order .list .item .item-info .text .name {
		width: 350rpx;
		color: #282828;
	}

	.my-order .list .item .item-info .text .money {
		text-align: right;
	}

	.my-order .list .item .totalPrice {
		font-size: 26rpx;
		color: #282828;
		text-align: right;
		margin: 27rpx 0 0 30rpx;
		padding: 0 30rpx 30rpx 0;
		border-bottom: 1rpx solid #eee;
	}

	.my-order .list .item .totalPrice .money {
		font-size: 28rpx;
		font-weight: bold;
	}

	.my-order .list .item .bottom {
		height: 107rpx;
		padding: 0 30rpx;
	}

	.my-order .list .item .bottom .bnt {
		width: 176rpx;
		height: 60rpx;
		text-align: center;
		line-height: 60rpx;
		color: #fff;
		border-radius: 50rpx;
		font-size: 27rpx;
	}

	.my-order .list .item .bottom .bnt.cancelBnt {
		border: 1rpx solid #ddd;
		color: #aaa;
	}

	.my-order .list .item .bottom .bnt~.bnt {
		margin-left: 17rpx;
	}

	.noCart {
		margin-top: 171rpx;
		padding-top: 0.1rpx;
	}

	.noCart .pictrue {
		width: 414rpx;
		height: 336rpx;
		margin: 78rpx auto 56rpx auto;
	}

	.noCart .pictrue image {
		width: 100%;
		height: 100%;
	}
</style>
